﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
using Might.Infrastructure.Annotations.Graphics;
using Might.Infrastructure.ModelicaDOM;
using TextAlignment = Might.Infrastructure.Annotations.Graphics.TextAlignment;

namespace Might.Modelica.Annotations.Graphics {
    ///<summary>
    ///</summary>
    [Mapping("Text")]
    public class GraphicsText : GraphicsFilledShapeEx, IGraphicsText {

        public GraphicsText() {
            Text = string.Empty;
            FontSize = 12;
            fontName = string.Empty;
            textStyle = new List<TextStyle>();
            horizontalAlignment = TextAlignment.Center;
        }

        #region IGraphicsText Members

        [Category("Common Properties")]
        [Mapping("textString")]
        public string Text {
            get { return text; }
            set {
                if (text != value) {
                    text = value;
                    OnChanged(this, "Text");
                }
            }
        }
        private string text;

        [Category("Text")]
        [Mapping("fonSize")]
        public double FontSize {
            get { return fontSize; }
            set {
                if (fontSize != value) {
                    fontSize = value;
                    OnChanged(this, "FontSize");
                }
            }
        }
        private double fontSize;

        [Category("Text")]
        public FontFamily FontName { get; set; }

        [Category("Layout")]
        public HorizontalAlignment Alignment { get; set; }

        #endregion

        #region Specific Modelica members

        // TODO not supported yet
        ///<summary>
        ///</summary>
        [Mapping("fontName")]
        public string fontName { get; set; }

        // TODO not supported yet
        ///<summary>
        ///</summary>
        [Mapping("textStyle")]
        public List<TextStyle> textStyle { get; set; }

        // TODO not supported yet
        ///<summary>
        ///</summary>
        [Mapping("horizontalAlignment")]
        public TextAlignment horizontalAlignment { get; set; }

        ///<summary>
        ///</summary>
        public override bool IsDefault {
            get {
                return base.IsDefault &&
                       Text == string.Empty &&
                       FontSize == 0 &&
                       fontName == string.Empty &&
                       textStyle.Count == 0 &&
                       horizontalAlignment == TextAlignment.Center;
            }
        }

        #endregion
    }
}